<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目申请查看</title>
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/themes/metro/easyui.css"
	rel="stylesheet" />
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/themes/mobile.css"
	rel="stylesheet" />
<link type="text/css"
	href="${pageContext.request.contextPath}/assets/css/common.css"
	rel="stylesheet" />
<style type="text/css">
.main {
	margin-right: 15px;
}

ul {
	list-style: none;
	padding:0px;
}

ul li{
    margin-bottom:10px;
}

.icon-list li a {
	cursor: pointer;
}
.choice{
    width:210px;
    display:inline-block;
}
.main .title{
    border-bottom:1px solid #CCC;
    padding:10px;
}
.main .title span{
    color:#555;
    font-size:14px;
    font-weight:bold;
}
.l-list ul{
    padding-left:10px;
    margin:0px;
}
</style>
</head>
<body>
	<div class="main">
	    <div class="title">
	            <span>申请人员筛选</span>
	    </div>
		<!--工具栏-->
		<div id="floatHead" class="toolbar-wrap">
			<div class="toolbar">
				<div class="box-wrap">
					<a class="menu-btn"></a>
					<div class="l-list">
					<ul>
					  <li>
					    <span>
					       <label>年龄：</label>
					       <input id="AGE_START" class="input"></input>
					    </span>
					           <label>到</label>
					    <span>
					        <input id="AGE_END" class="input"></input>&nbsp;岁
					    </span>
					  </li>
					  <li>
					  <span class="choice">
					    <label>性别：</label>
					    <input id="SEX" style="height: 32px;" class="input"></input>
					  </span>
					  <span class="choice">
					    <label>婚姻：</label>
					    <input id="MARRIAGE" style="height: 32px;" class="input"></input>
					  </span>
					  </li>
<!-- 					  <li>
					  <span class="choice">
					    <label>身高：</label>
					    <input id="HEIGHT" class="input"></input>
					    <label>cm</label>
					  </span>
                      <span class="choice">
					    <label>体重：</label>
					    <input id="WEIGHT" class="input"></input>
					    <label>kg</label>
					  </span>
					  </li> -->
					  <li>
					    <label>地区：</label>
					    <input id="PROVINCE" style="height: 32px;" class="input"></input>&nbsp;省/直辖市
					    <input id="CITY" style="height: 32px;" class="input"></input>&nbsp;市
					    <!-- <input id="AREA" style="height: 32px;" class="input"></input>&nbsp;区/县 -->&nbsp;&nbsp;
					    <button class="btn" onclick="search()">根据条件过滤</button>
					    <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
					  </li>
					  <li>

					  </li>
					</ul>		
					</div>
<!-- 					<div class="r-list">
						<input id="search" class="keyword" /> <a href="javascript:void(0);" class="btn-search"
							onclick="searchItem()">查询</a>
					</div> -->
				</div>
			</div>
		</div>
		<!--/工具栏-->

		<table id="tt"></table>
	</div>

	<input type="hidden" id="code" value="${code}" />
	<script
		src="${pageContext.request.contextPath}/assets/js/jquery-1.11.2.min.js"
		charset="utf-8" type="text/javascript"></script>
	<script
		src="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/jquery.easyui.min.js"
		charset="utf-8" type="text/javascript"></script>
	<script
		src="${pageContext.request.contextPath}/assets/plugins/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"
		charset="utf-8" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/assets/js/common.js" 
		type="text/javascript" charset="utf-8"></script>	
	<script type="text/javascript">
	var contextPath = '<%=request.getContextPath()%>';
	var item_code=$('#code').val();
	$(function(){
		getCombobox();
		getTableList('',1);
		$(window).resize(function() {
			//延迟执行,防止多次触发
			setTimeout(function() {
				$('#tt').datagrid('resize');
			}, 100);
		});
	})
	/*获取数据列表*/
	function getTableList(searchString,searchFlag) {//searchFlag 1 无筛选条件 2通过筛选条件筛选
		$('#tt').datagrid({
	        //height: $('body').height() - 270,
	        nowrap: true,
	        striped: true,
	        collapsible: false,
	        remoteSort: false,
	        selectOnCheck: false,
	        checkOnSelect: false,
	        singleSelect: true,
	        fitColumns: true,
	        url: contextPath + "/bg/IM112.do?item_code="+item_code+"&rnd=" +Math.random()+'$searchFlag='+searchFlag+searchString,
	        columns: [[
	            {
	                field: 'NAME',
	                title: '姓名',
	                align: 'center',
	                width: 100,
								},
	            {
	                field: 'ID_NUMBER',
	                title: '身份证号',
	                align: 'center',
	                width: 100
								},
	            {
	                field: 'AGE',
	                title: '年龄',
	                align: 'center',
	                width: 100
								},
				{
					field: 'SEX',
					title: '性别',
					align: 'center',
					width: 100
								},								
	            {
	                field: 'MARRIAGE',
	                title: '婚姻状况',
	                align: 'center',
	                width: 100
								},
				{
					field: 'PHONE_NUMBER',
					title: '手机号',
					align: 'center',
					width: 100
								},
				{
					field: 'CREATE_DATE',
					title: '申请时间',
					align: 'center',
					width: 100
								}
								]],
	        pagination: true,
	        pageSize: 10,
	        pageList: [10, 15, 30, 40]
	    });		
	}
	//查询
	//获取combobox
		function getCombobox() {
		    //性别 婚姻
			$.ajax({
				url : contextPath + "/bg/IM113.do",
				data : {
					"rnd" : Math.random()
				},
				dataType : 'json',
				success : function(data, textStatus, jqXHR) {
					var sex=data.sex;
					var marriage=data.marriage;
					var sexObj=eval("(" + func(sex) + ")");
					//sexObj.push({ "text": "不限", "id": 0 });
					$('#SEX').combobox({
						data : sexObj,
						valueField : 'id',
						textField : 'text'
					});	
					$('#SEX').combobox("setValue",'0');
					var marriageObj=eval("(" + func(marriage) + ")");
					//marriageObj.push({ "text": "不限", "id": 0 });
					$('#MARRIAGE').combobox({
						data : marriageObj,
						valueField : 'id',
						textField : 'text'
					});		
					$('#MARRIAGE').combobox("setValue",'0');
				}
			})
			//省市区
			$.ajax({
				url : contextPath + "/bg/D101.do",
				data : {
					"PARENT":'province_city_area',
					"rnd" : Math.random()
				},
				dataType : 'json',
				success : function(data, textStatus, jqXHR) {
					if(data.status='true'){
						$('#PROVINCE').combobox({
							data : data.record,
							valueField : 'id',
							textField : 'text',
							onSelect:function(record){
								getCity(record.id);
							}
						});	
					}
				}
			})
			
			$('#CITY').combobox({
				valueField : 'id',
				textField : 'text'
			});	
/* 			$('#AREA').combobox({
				valueField : 'id',
				textField : 'text'
			});	 */
		}
	    //获取市
	    function getCity(provice_id){
			$.ajax({
				url : contextPath + "/bg/D101.do",
				data : {
					"PARENT":provice_id,
					"rnd" : Math.random()
				},
				dataType : 'json',
				success : function(data, textStatus, jqXHR) {
					if(data.status='true'){
						$('#CITY').combobox({
							data : data.record,
							onSelect:function(record){
								//getArea(record.id);
							}
						});	
						$('#CITY').removeAttr('disabled');
					}
				}
			})
	    }
	    //获取县/区
	    function getArea(city_id){
			$.ajax({
				url : contextPath + "/bg/D101.do",
				data : {
					"PARENT":city_id,
					"rnd" : Math.random()
				},
				dataType : 'json',
				success : function(data, textStatus, jqXHR) {
					if(data.status='true'){
						$('#AREA').combobox({
							data : data.record,
						});	
						$('#AREA').removeAttr('disabled');
					}
				}
			})
	    }
		//循环
		function func(result){
			var json = '';
			for (var j = 0; j < result.length; j++) {
				json += '{"id":' + result[j].id + ',"text":"'
						+ result[j].name + '"},'
			}
			if (json.length > 0) {
				json = json.substring(0, json.length - 1);
			}
			json = '[' + json + ']';
			return json;
		}
		//根据条件过滤
		function search(){
			var AGE_START=$('#AGE_START').val();
			var AGE_END=$('#AGE_END').val();
			if(AGE_START!=''&&AGE_END!=''){
				if(parseInt(AGE_START)>parseInt(AGE_END)){
		  			$.messager.show({title:'提示',msg:'开始年龄不能大于结束年龄！',showType:'slide'});
		  			$('#AGE_START').focus();
		  			return;
				}
			}
			var SEX=$('#SEX').combobox('getValue');//0 无
			var MARRIAGE=$('#MARRIAGE').combobox('getValue');//0 无
			var HEIGHT='';
			var WEIGHT='';
/* 			var HEIGHT=$('#HEIGHT').val();
			var WEIGHT=$('#WEIGHT').val(); */
			var PROVINCE=$('#PROVINCE').combobox('getText');
			var CITY=$('#CITY').combobox('getText');
			//var AREA=$('#AREA').combobox('getText');
			var AREA='';
			
			var searchString='&AGE_START='+AGE_START+'&AGE_END='+AGE_END+'&SEX='+SEX
			+'&MARRIAGE='+MARRIAGE+'&HEIGHT='+HEIGHT+'&WEIGHT='+WEIGHT+'&PROVINCE='+encodeURI(PROVINCE)
			+'&CITY='+encodeURI(CITY)+'&AREA='+encodeURI(AREA);
			
			getTableList(searchString,2);
		}
	</script>
</body>
</html>